var app = getApp()
Page({

  data: {
    dates: '请选择日期',
    time:'请选择时间',
    userTelephone: '',
    sendtime: '',
    userName:'',
    img:'',
    name:'',
    userid:'',
    nickname:'',
    describe:'',
    successInfo: {}

  },
  onLoad: function(options) {
    console.log(options)
    console.log("595")
    wx.showLoading({
      title: '请稍候',
    })
    this.setData({
      userid: options.id,
      img: options.img,
      name: options.name,
      nickname: options.nickname,
      describe: options.describe
    })
  },
  send: function () {
    var that = this
    var timeArr = ''
    timeArr = ''+that.data.dates +' '+ that.data.time
    console.log(timeArr)
    console.log(that.data.userName)
    console.log(that.data.userTelephone)
    console.log(that.data.userid)
    console.log(app.globalData.myId)
    wx.request({
      url: 'https://xiaochengxu.fincoder.com/index.php/Home/Consult/order_add',
      data: {
        types: 1,
        bespeak_time: timeArr,
        name: that.data.userName,
        phone: that.data.userTelephone,
        ser_id: that.data.userid,
        myId: app.globalData.myId
      },
      method: 'POST',
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      success: function (res) {
        console.log(res)
        console.log("9999")
        if (res.data.status === 1) {
          that.setData({
            successInfo: res.data.data
          })
          wx.navigateTo({
            url: '../summonSuccess/summonSuccess?successInfo=' + JSON.stringify(that.data.successInfo),
          })
        
          that.setData({
            successInfo: res.data.data
          })


        } else {
          wx.hideLoading()
          wx.showModal({
            title: '提示',
            content: '请求失败',
            showCancel: false
          })
        }

      },
      fail: function () {
        wx.hideLoading()
        wx.showModal({
          title: '提示',
          content: '请求失败',
          showCancel: false
        })
      }


    })
  },
  q: function () {
    wx.navigateBack({ changed: true })
  },
  qq: function () {
    wx.switchTab({

      url: '/pages/index/index',

    });
  },
  onReady: function () {
    const vm = this
    vm.setData({
      statusBarHeight: getApp().globalData.statusBarHeight,
      titleBarHeight: getApp().globalData.titleBarHeight
    })
    wx.hideLoading()
  },

  onShow: function() {
 
  },

  userNameInput: function(e) {
    this.setData({
      dates: e.detail.value
    })
  },
  bindTimeChange: function (e) {
    this.setData({
      time: e.detail.value
    })
  },
  userTelephone: function(e) {
    this.setData({
      userTelephone: e.detail.value
    })
  },
  userEnterprise: function (e) {
    this.setData({
      userEnterprisee: e.detail.value
    })
  },
  userName: function (e) {
    this.setData({
      userName: e.detail.value
    })
  },
 
  toSummonSuccess: function () {
    wx.navigateTo({
      url: '../summonSuccess/summonSuccess',
    })
  },
})